package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseHouseInfo;
import com.softer.wxzj.entity.BaseModifyDetail;
import com.softer.wxzj.service.BaseModifyDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wxr
 * @create 2019/5/9 - 17:09 - 星期日
 */

@RestController
@RequestMapping("/baseModifyDetail")
@Slf4j
public class BaseModifyDetailController {
    @Autowired
    BaseModifyDetailService baseModifyDetailService;

    /**
     * 获取变更审核的信息详情
     *
     * @param page
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "获取业委会变更审核信息详情列表", operationUnit = LogOperationUnit.BASE_MODIFY, operationType = LogOperationType.SELECT)
    public PageInfo<BaseModifyDetail> getAuditUpdateList(Page page, BaseModifyDetail baseModifyDetail) {
        return baseModifyDetailService.getList(page, baseModifyDetail);
    }

    /**
     * 结构维护新增房屋
     *
     * @param reqNo
     * @return
     */
    @RequestMapping("/selectAllList")
    public List<BaseHouseInfo> selectAllList(String reqNo) {
        return baseModifyDetailService.selectAllList(reqNo);
    }

    /**
     * 新增房屋
     * @param baseHouseInfo
     * @return
     */
    @RequestMapping("/addHouse")
    public CommonResult addHouse(@RequestBody List<BaseHouseInfo> baseHouseInfo) {
        return baseModifyDetailService.addHouse(baseHouseInfo);
    }
    /**
     * 删除房屋
     * @param id    房屋id
     * @param reqNo  变更id
     * @return
     */
    @RequestMapping("/delHouse")
    public CommonResult delHouse(String id,String reqNo) {
        return baseModifyDetailService.delHouse(id,reqNo);
    }
    /**
     * 查询结构变更应不应跳页
     */
    @RequestMapping("/changePage")
    public int changePage(String reqNo) {
        return baseModifyDetailService.changePage(reqNo);
    }


    /**
     * 获取变更审核的信息详情
     *
     * @param page
     * @return
     */
    @RequestMapping("/getListByCell")
    @LogRecord(description = "获取单元变更审核信息详情列表", operationUnit = LogOperationUnit.BASE_MODIFY, operationType = LogOperationType.SELECT)
    public PageInfo<BaseModifyDetail> getListByCell(Page page,String id) {
        return baseModifyDetailService.getListByCell(page,id);
    }

    /**
     * 获取变更审核的信息详情
     *
     * @param page
     * @return
     */
    @RequestMapping("/getListByHouse")
    @LogRecord(description = "获取房屋结构变更审核信息详情列表", operationUnit = LogOperationUnit.BASE_MODIFY, operationType = LogOperationType.SELECT)
    public PageInfo<BaseModifyDetail> getListByHouse(Page page,String id) {
        return baseModifyDetailService.getListByHouse(page,id);
    }

}
